package com.my.chapter10;

public class practice2 {
    public static void main(String[] args) {
        Sequence s = new Sequence(10);
        for(int i=0;i<10;i++){
            s.add(new P01("A"+i));
        }
        s.display();
    }
}

class P01{
    String content;
    P01(String c){
        content = c;
    }

    @Override
    public String toString() {
        return "P01{" +
                "content='" + content + '\'' +
                '}';
    }
}

class Sequence{
    private Object[] items;
    private int next = 0;
    public Sequence(int size){
        items = new Object[size];
    }
    void add(Object x){
        if(next < items.length){
            items[next++] = x;
        }
    }
    void display(){
        for(int i=0;i<next;i++){
            System.out.println(items[i]);
        }
    }
}
